package com.qf.test;

import com.baomidou.mybatisplus.core.MybatisSqlSessionFactoryBuilder;
import com.qf.dao.UserDao;
import com.qf.pojo.User;
import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;
import org.apache.log4j.lf5.util.Resource;
import org.junit.Test;

import java.io.InputStream;
import java.util.List;

/**
 * @author ShenZhuoPing
 * @version V1.0
 * @Project Mybatis_plus_Demo
 * @Package com.qf.test
 * @Description:
 * @Date 2022/7/18 10:05
 */
public class Mybatis_Plus {
    @Test
    public void test01() throws Exception{
        String  resource="mybatis_config.xml";
        InputStream inputStream = Resources.getResourceAsStream(resource);
//        SqlSessionFactory sqlSessionFactory=new SqlSessionFactoryBuilder().build(inputStream);
        SqlSessionFactory sqlSessionFactory=new MybatisSqlSessionFactoryBuilder().build(inputStream);
        SqlSession sqlSession = sqlSessionFactory.openSession();
        UserDao userDao = sqlSession.getMapper(UserDao.class);
        List<User> users = userDao.selectList(null);
        for (User user : users) {
            System.out.println(user);
        }
    }
}
